<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        select{
            width: 200px;
            height: 200px;
        }
    </style>
    <script src="../jquery-1.12.4.js"></script>
    <script>
        $(function(){
            //点击>>左边的下拉框全部过去右边
            $('#btn3').click(function(){
                $('#sel1 option').appendTo($('#sel2'))
            })
            //点击<<全部过来左边
            $('#btn4').on('click',function(){
                $('#sel2 option').appendTo($('#sel1'))
            })
            //点击>将选中的移到右边
            $('#btn1').on('click',function(){
                $('#sel1 option:selected').appendTo($('#sel2'))
            })
            //点击<将右边的移到左边
            $('#btn2').on('click',function(){
                $('#sel2 option:selected').appendTo($('#sel1'))
            })
        })
    </script>
</head>
<body>
    <select name="" id="sel1" multiple>
        <option value="">a</option>
        <option value="">b</option>
        <option value="">c</option>
        <option value="">d</option>
        <option value="">e</option>
        <option value="">f</option>
    </select>
    <button id='btn1'>&gt;</button>
    <button id='btn2'>&lt;</button>
    <button id='btn3'>&gt;&gt;</button>
    <button id='btn4'>&lt;&lt;</button>
    <select name="" id="sel2" multiple></select>
</body>
<!-- <script>
    //获取元素
    var sel1 = document.getElementById('sel1');
    var sel2 = document.getElementById('sel2');
    var btn1 = document.getElementById('btn1');
    var btn2 = document.getElementById('btn2');
    var btn3 = document.getElementById('btn3');
    var btn4 = document.getElementById('btn4');

    //注册事件
    //点击>>将sel1所有子元素移动到sel2
    btn3.onclick = function(){
        for(var i = 0; i < sel1.children.length; i++){
            sel2.appendChild(sel1.children[i])
            i--;
        }
    }
    //点击<<将sel2的所有子元素移动到sel1
    btn4.onclick = function(){
        for(var i = 0; i < sel2.children.length; i++) {
            sel1.appendChild(sel2.children[i]);
            i--;
        }
    }
    //点击>将选中的sel1移动到sel2
    btn1.addEventListener('click',function(){
        for(var i = 0; i < sel1.children.length; i++) {
            if(sel1.children[i].selected){
                sel2.appendChild(sel1.children[i]);
                i--;
            }
        }
    },false)
    //点击<将选中的sel2子元素移动到sel1
    btn2.addEventListener('click',function(){
        for(var i = 0; i < sel2.children.length; i++) {
            if(sel2.children[i].selected) {
                sel1.appendChild(sel2.children[i]);
                i--
            }
        }
    },false)
</script> -->
</html>